#include <iostream>
#include <signal.h>
#include <unistd.h>

void handler(int sig)
{
    std::cout << "receive a signal: " << sig << std::endl;
    sleep(1);
}

int main()
{
    signal(SIGSEGV, handler);
    sleep(1);

    int* ptr = nullptr;
    *ptr = 10;

    while (1);
    return 0;
}